var setting = {
			view: {
				showLine: true,
				fontCss: getFont
			},
			data: {
				simpleData: {
					enable: true
				},
	            key: {
	                title: "desc"
	            }
			}
			/*  ,callback: {
				onClick: OnTreeClick
			}  */
		};
	
	function getFont(treeId, node) {
		return node.font ? node.font : {};
	}

	
	var sid = '${sid}';
	
	function showWin(winTitle,winUrl,winWidth,winHeight) {
		var winContent = '<iframe scrolling="auto" frameborder="0"  src="'+ winUrl+ '" style="width:100%;height:100%;"></iframe>';
		$('#w_win').window({ width: winWidth, height: winHeight, title: winTitle, content : winContent }).window('center').window('open');
	}
	function close_w() {
		$('#w_win').window('close');
	}
	var str;
	var idtype;
	function putStr(str1,idtype1)
	{
		str=str1;
		idtype=idtype1;
	}
	
	function winWF(winTitle,winUrl,winWidth,winHeight) {
		var winContent = '<iframe scrolling="auto" frameborder="0"  src="'+ winUrl+ '" style="width:100%;height:100%;"></iframe>';
		$('#w_wf').window({ width: winWidth, height: winHeight, title: winTitle, content : winContent }).window('center').window('open');
	}

	function winOffice(winTitle,winUrl,winWidth,winHeight) {
		var winContent = '<iframe scrolling="auto" frameborder="0"  src="'+ winUrl+ '" style="width:100%;height:100%;"></iframe>';
		$('#w_office').window({ width: winWidth, height: winHeight, title: winTitle, content : winContent }).window('center').window('open');
	}
	
	function doTree(pid,pname)
 	{
		$("#p_title").panel({
			title:pname
		});
 		$.ajax({
			type : "POST",
			url : "${ctx}/platform/getMenuTree",
			data : {
				ccode : pid
			},
			dataType : 'text',
			success : function(data) {
				var json = eval('(' + data + ')'); 
				$.fn.zTree.init($("#tree_list"), setting, json);
			}
		});
 	}
	
	function close_main_w()
	{
		$('#w_win').window('close');
	}
	
	
	function TopShowWin(title,url,width,height)
	{
		// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
        	width = 800;
        }
        if ($.common.isEmpty(height)) {
        	height = ($(window).height() - 50);
        }
		top.layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    		fix: false,
    		//不固定
    		maxmin: true,
    		shade: 0.3,
    		title:title,
    		content: url,
    		btn: ['关闭'],
    	    // 弹层外区域关闭
    		shadeClose: true,
    	    cancel: function(index) {
    	        return true;
    	    }
    	});
	}
	
	function TopShow(title,url,width,height)
	{
		// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
        	width = 800;
        }
        if ($.common.isEmpty(height)) {
        	height = ($(window).height() - 50);
        }
		top.layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    		fix: false,
    		//不固定
    		maxmin: true,
    		shade: 0.3,
    		title:title,
    		content: url, 
    	    // 弹层外区域关闭
    		shadeClose: true
    	});
	}
	
	
	function TopShowWinFull(title,url,width,height)
	{
		// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
        	width = 800;
        }
        if ($.common.isEmpty(height)) {
        	height = ($(window).height() - 50);
        }
		var index = top.layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    		fix: false,
    		//不固定
    		maxmin: true,
    		shade: 0.3,
    		title:title,
    		content: url,
    		btn: [ '关闭'],
    	    // 弹层外区域关闭
    		shadeClose: true,
    	    cancel: function(index) {
    	        return true;
    	    }
    	});
        top.layer.full(index);
	}
	
	function TopShowWinFullNoBtn(title,url,width,height)
	{
		// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
        	width = 800;
        }
        if ($.common.isEmpty(height)) {
        	height = ($(window).height() - 50);
        }
		var index = top.layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    		fix: false,
    		//不固定
    		maxmin: true,
    		shade: 0.3,
    		title:title,
    		content: url,
    		btn: []
    	});
        top.layer.full(index);
	}
	

	 //焦点图片预览
	function PreviewImage(fileObj,imgPreviewId,divPreviewId) {
	        var allowExtention = ".jpg,.bmp,.gif,.jpeg,.png";//允许上传文件的后缀名document.getElementById("hfAllowPicSuffix").value;
	        var extention = fileObj.value.substring(fileObj.value.lastIndexOf(".") + 1).toLowerCase();
	        if (allowExtention.indexOf(extention) > -1) {
	            if (fileObj.files) {//HTML5实现预览，兼容chrome、火狐7+等
	                if (window.FileReader) {
	                    var reader = new FileReader();
	                    reader.onload = function (e) {
	                        var tempDivPreview=document.getElementById(divPreviewId);
	                        tempDivPreview.style.display="block";
	                        document.getElementById(imgPreviewId).setAttribute("src", e.target.result);
	                    }
	                    if(fileObj.files[0]) {
	                        reader.readAsDataURL(fileObj.files[0]);
	                    }
	                }
	            } else {
	                document.getElementById(imgPreviewId).setAttribute("src", fileObj.value);
	            }
	        } else {
	            alert("仅支持" + allowExtention + "为后缀名的文件!");
	            fileObj.value = "";//清空选中文件
	            fileObj.outerHTML = fileObj.outerHTML;
	        }
	}
	
    function openWin(title, url, width, height) {
    	// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
    	    url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
    	    width = 800;
        }
        if ($.common.isEmpty(height)) {
    	    height = ($(window).height() - 50);
        }
    	layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    	    fix: false,
    	    //不固定
    	    maxmin: true,
    	    shade: 0.3,
    	    title: title,
    	    content: url,
    	    btn: ['关闭'],
    	    // 弹层外区域关闭
    	    shadeClose: true,
    	    cancel: function(index) {
    	        return true;
    	    }
    	});
    }
    
    function openWinFull(title, url, width, height) {
    	// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
        	width = 800;
        }
        if ($.common.isEmpty(height)) {
        	height = ($(window).height() - 50);
        }
    	var index = layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    	    fix: false,
    	    //不固定
    	    maxmin: true,
    	    shade: 0.3,
    	    title: title,
    	    content: url,
    	    btn: ['关闭'],
    	    // 弹层外区域关闭
    	    shadeClose: true,
    	    cancel: function(index) {
    	        return true;
    	    }
    	});
        layer.full(index);
    }
    
    
    function openWinSave(title, url, width, height) {
    	// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
    	    url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
    	    width = 800;
        }
        if ($.common.isEmpty(height)) {
    	    height = ($(window).height() - 50);
        }
    	layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    	    fix: false,
    	    //不固定
    	    maxmin: true,
    	    shade: 0.3,
    	    title: title,
    	    content: url,
            btn: ['保存', '关闭'],
            // 弹层外区域关闭
            shadeClose: true,
            yes: function(index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler(index, layero);
            },
    	    cancel: function(index) {
    	        return true;
    	    }
    	});
    }
    function openWinS(title, url, width, height) {
    	// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
    	    url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
    	    width = 800;
        }
        if ($.common.isEmpty(height)) {
    	    height = ($(window).height() - 50);
        }
    	layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    	    fix: false,
    	    //不固定
    	    maxmin: true,
    	    shade: 0.3,
    	    title: title,
    	    content: url,
            btn: ['选择', '关闭'],
            // 弹层外区域关闭
            shadeClose: true,
            yes: function(index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler(index, layero);
            },
    	    cancel: function(index) {
    	        return true;
    	    }
    	});
    }
    
    function openWinFullSave(title, url, width, height) {
    	// 如果是移动端，就使用自适应大小弹窗
    	if ($.common.isMobile()) {
    	    width = 'auto';
    	    height = 'auto';
    	}
    	if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
        	width = 800;
        }
        if ($.common.isEmpty(height)) {
        	height = ($(window).height() - 50);
        }
    	var index = layer.open({
    	    type: 2,
    	    area: [width + 'px', height + 'px'],
    	    fix: false,
    	    //不固定
    	    maxmin: true,
    	    shade: 0.3,
    	    title: title,
    	    content: url,
            btn: ['保存', '关闭'],
            // 弹层外区域关闭
            shadeClose: true,
            yes: function(index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler(index, layero);
            },
    	    cancel: function(index) {
    	        return true;
    	    }
    	});
        layer.full(index);
    }
    
    
   function S4() {
   	return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
	}
	function guid() {
	   return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
	}


function showWinFull(title,url,callback)
{
	//iframe层-父子操作
	var index = showWinFullCall(title,url,function(){});
	return index;
}
function showWinFullCall(title,url,callback)
{
	//iframe层-父子操作
	var index = layer.open({
		title:title,
		type: 2,
		area: ['100%', '100%'],
		fixed: false, //不固定
		maxmin: true,
		content: url,
		end:function(){
			if (typeof callback == "function") {
				callback();
			}
		}
	});
	layer.full(index);
	return index;
}

function showWin(title,url,width,height)
{
	var index = showWinCall(title,url,width,height,function(){})
	return index;
}
function showWinCall(title,url,width,height,callback)
{
	//iframe层-父子操作
	var index = layer.open({
		title:title,
		type: 2,
		area: [width+'px', height+'px'],
		fixed: false, //不固定
		maxmin: true,
		content: url,
		end:function(){
			if (typeof callback == "function") {
				callback();
			}
		}
	});

	return index;
}


/*用户管理-头像*/
function openTop(title,url) {
	top.layer.open({
		type: 2,
		area: ['80%','80%'],
		fix: false,
		//不固定
		maxmin: true,
		shade: 0.3,
		title:title,
		content: url,
		btn: ['确定', '关闭'],
		// 弹层外区域关闭
		shadeClose: true,
		yes: function(index, layero) {
			var iframeWin = layero.find('iframe')[0];
			iframeWin.contentWindow.submitHandler(index, layero);
		},
		cancel: function(index) {
			return true;
		}
	});
}

/*用户管理-头像*/
function openTopFull(title,url) {
	top.layer.open({
		type: 2,
		area: ['100%','100%'],
		fix: false,
		//不固定
		maxmin: true,
		shade: 0.3,
		title:title,
		content: url,
		btn: ['确定', '关闭'],
		// 弹层外区域关闭
		shadeClose: true,
		yes: function(index, layero) {
			var iframeWin = layero.find('iframe')[0];
			iframeWin.contentWindow.submitHandler(index, layero);
		},
		cancel: function(index) {
			return true;
		}
	});
}

/*用户管理-头像*/
function openTopFullDetail(title,url) {
	top.layer.open({
		type: 2,
		area: ['100%','100%'],
		fix: false,
		//不固定
		maxmin: true,
		shade: 0.3,
		title:title,
		content: url,
		btn: ['关闭'],
		// 弹层外区域关闭
		shadeClose: true,
		cancel: function(index) {
			return true;
		}
	});
}

/*用户管理-头像*/
function openTopWin(title,url,width,height) {
	top.layer.open({
		type: 2,
		area: [width+'px',height+'px'],
		fix: false,
		//不固定
		maxmin: true,
		shade: 0.3,
		title:title,
		content: url,
		btn: ['确定', '关闭'],
		// 弹层外区域关闭
		shadeClose: true,
		yes: function(index, layero) {
			var iframeWin = layero.find('iframe')[0];
			iframeWin.contentWindow.submitHandler(index, layero);
		},
		cancel: function(index) {
			return true;
		}
	});
}


/*用户管理-头像*/
function openTopRate(title,url) {
	top.layer.open({
		type: 2,
		area: ['85%','85%'],
		fix: false,
		//不固定
		maxmin: true,
		shade: 0.3,
		title:title,
		content: url,
		btn: ['关闭'],
		// 弹层外区域关闭
		shadeClose: true,
		cancel: function(index) {
			return true;
		}
	});
}